var msgModaldefault = "Are you sure you want to proceed?";
function object_properties_node(object_type,parent_id,child_id) {
    
    var json_nodes = $("body").data();
    var json_nodes_var = json_nodes['nodes'];
    var ret = "";
    var output = "";
        ret += '<div style="float:left;width:50%;">';
            ret += '<h3 class="pull-left">';
            if(object_type=="workflow_chart-email"){
                ret += '<i class="icon-asterisk fa fa-envelope"></i> ' + "Message Notification";
            }else if(object_type=="workflow_chart-fields-trigger"){
                ret += '<i class="icon-asterisk fa fa-bolt"></i> ' + "Trigger";
            }else if(object_type=="workflow_chart-user_setup"){
                ret += '<i class="icon-user fa fa-user"></i> ' + "Users";
            }else{
                ret += '<i class="icon-asterisk fa fa-gear"></i> ' + "Properties";
            }
                
            ret += '</h3>';
        ret += '</div>';
        ret += '<div style="float:right;width:50%;text-align:right;margin-top:-5px;">';
            ret += '<input type="button" class="btn-blueBtn settings-to-json fl-margin-right fl-margin-bottom" object_type="'+ object_type +'" id="" value="Ok" node-data-id="'+ parent_id +'" style=""> &nbsp;';
            ret += '<input type="button" class="btn-basicBtn cancel_dialog fl-margin-bottom" object_type="'+ object_type +'" id="popup_cancel" node-data-id="'+ parent_id +'" value="Cancel" onclick="removeDialog(this)">';
        ret += '</div>';
        ret += '<div class="hr"></div>';
    switch (object_type) {
        //ORGANIZATIONAL CHART
        case "organizational_chart":
        ret += '<div id="content-dialog-scroll" style="position: relative; margin: 0px auto; padding: 0px; height: 300px;overflow: hidden;" class="ps-container">';
        ret += '<input type="text" value="'+ parent_id +'" class="display node_data_id" >';
        ret +='<div class="content-dialog" style="height: auto;">';
        var orgchart_dept_name = if_undefinded(json_nodes_var[''+ parent_id +'']['node_text'],"");
        var orgchart_node_color = if_undefinded(json_nodes_var[''+ parent_id +'']['node_color'],"#FFF");
        var orgchart_user_head = if_undefinded(json_nodes_var[''+ parent_id +'']['orgchart_user_head'],"");
        var orgchart_dept_assistant = if_undefinded(json_nodes_var[''+ parent_id +'']['orgchart_dept_assistant'],"");
        var orgchart_dept_members = if_undefinded(json_nodes_var[''+ parent_id +'']['orgchart_dept_members'],"");
            ret += '<div class="fields_below">';
                ret += '<div class="label_below2">Department Name: <font color="red">*</font></div>';
                ret += '<div class="input_position_below">';
                    ret += '<input type="text" name="" class="form-text obj_prop" id="orgchart-dept-name" value="';
                        if (orgchart_dept_name=="") {
                            ret += "Node";
                        }else{
                            ret += orgchart_dept_name;
                        }
                    ret += '">';
                ret += '</div>';
            ret += '</div>';
            ret += '<div class="fields_below">';
                ret += '<div class="label_below2">Node Color:</div>';
                ret += '<div class="input_position_below">';
                    ret += '<input type="text" class="chngColor" id="orgchart-node-color" data-properties-type="nodeColor" value="'+ orgchart_node_color +'">';
                ret += '</div>';
            ret += '</div>';
            ret += '<div style="float:left;width:32%;margin-right:10px">';
                ret += '<div class="fields_below">';
                    ret += '<div class="label_below2">Head: <font color="red">*</font></div>';
                    ret += '<div class="input_position_below prop_option_list_column_1">';
                        ret += '<input type="text" name="" class="form-text orgchart-user-search" id="orgchart-head-search" style="" placeholder="Search..">';
                        ret += '<div class="loadHeadUser" style="border-top:none !important;background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;">';
                        //ret += '<input type="text" data-tag-id="0" name="" id="orgchart-user-head" class="form-text obj_prop" id="" value="'+ orgchart_user_head +'">';
                        // Get Head User 
                        ret += '</div>';
                    ret += '</div>';
                ret += '</div>';
            ret += '</div>';
            ret += '<div style="float:left;width:32%;margin-right:10px">';
                ret += '<div class="fields_below">';
                    ret += '<div class="label_below2">Assistant Head: </div>';
                    ret += '<div class="input_position_below prop_option_list_column_2">';
                    ret += '<input type="text" name="" class="form-text orgchart-user-search" id="orgchart-assistant-head-search" style="" placeholder="Search..">';
                        ret += '<div class="loadAssistantHeadUser" style="border-top:none !important;background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;">';
                        //ret += '<input type="text" data-tag-id="0" name="" id="orgchart-user-head" class="form-text obj_prop" id="" value="'+ orgchart_user_head +'">';
                        
                        ret += '</div>';
                    ret += '</div>';
                ret += '</div>';
            ret += '</div>';
            ret += '<div style="float:left;width:31%;margin-right:10px">';
                ret += '<div class="fields_below">';
                    ret += '<div class="label_below2">Member: </div>';
                    ret += '<div class="input_position_below prop_option_list_column_3">';
                    ret += '<input type="text" name="" class="form-text orgchart-user-search" id="orgchart-member-search" style="" placeholder="Search..">';
                        ret += '<div class="loadMemberUser" style="border-top:none !important;background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;">';
                        
                        ret += '</div>'
                    ret += '</div>';
                ret += '</div>';
            ret += '</div>';
            ret += '</div>';
            ret +='</div>';
            return ret;
            break;
        //WORKFLOW - PROCESSOR NODE
        case "workflow_chart-processor":
            var workflow_processor_type = if_undefinded(json_nodes_var[''+ parent_id +'']['processorType'],"");
            var workflow_processor = if_undefinded(json_nodes_var[''+ parent_id +'']['processor'],"");
            var workflow_status = if_undefinded(json_nodes_var[''+ parent_id +'']['status'],"");
            var workflow_field_enabled = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldEnabled'],"");
            var workflow_field_required = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldRequired'],"");
            var workflow_field_hidden = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldHiddenValue'],"");
            var workflow_field_read_only = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldReadOnly'],"");
            var workflow_processor_button = if_undefinded(json_nodes_var[''+ parent_id +'']['buttonStatus'],"");
            var workflow_default_action = if_undefinded(json_nodes_var[''+ parent_id +'']['workflow-default-action'],"");
            var workflow_escalation_period = if_undefinded(json_nodes_var[''+ parent_id +'']['workflow-escalation-period'],"");
            var form_fields = $(".form_fields").val();
            form_fields = JSON.parse(form_fields);
            ret += '<div id="content-dialog-scroll" style="position: relative; margin: 0px auto; padding: 0px; width: 100%; max-height: 500px;overflow: hidden;" class="ps-container">';
            ret +='<div class="content-dialog" style="width: 97%;height: auto;">';
                    ret += '<div style="float: left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Processor Type: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select" id="workflow-processor-type" style="margin-top:0px">';
                                    ret += '<option value="0" '+ setSelected("0", workflow_processor_type) +'>--Select--</option>';
                                    ret += '<option value="1" '+ setSelected("1", workflow_processor_type) +'>Department Position</option>';
                                    ret += '<option value="2" '+ setSelected("2", workflow_processor_type) +'>Company Position</option>';
                                    ret += '<option value="3" '+ setSelected("3", workflow_processor_type) +'>Employee</option>';
                                    ret += '<option value="4" '+ setSelected("4", workflow_processor_type) +'>Requestor</option>';
                                    ret += '<option value="5" '+ setSelected("5", workflow_processor_type) +'>Field</option>';
                                ret += '</select>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Processor: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select" id="workflow-processor" style="margin-top:0px">';
                                ret += '<option value="0">--Select--</option>';
                                ret += '</select>';
                                ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Status: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-status" data-properties-type="lblFldName" data-object-id="" placeholder="Status" value="'+ workflow_status +'" style="height:32px">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Default Action:</div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select" id="workflow-default-action" style="margin-top:0px">';
                                ret += '<option value="0">--Select--</option>';
                                if(workflow_processor_button){
                                    for(var i in workflow_processor_button){
                                        ret += '<option value="'+ workflow_processor_button[i]['child_id'] +'" '+ setSelected(workflow_processor_button[i]['child_id'], workflow_default_action) +'>'+ workflow_processor_button[i]['button_name'] +'</option>';
                                    }
                                }
                                ret += '<option value="cancel" '+ setSelected('cancel', workflow_default_action) +'>Cancel</option>';
                                ret += '</select>';
                                ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Escalation Period(Day/s): </div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select" id="workflow-escalation-period" style="margin-top:0px">';
                                for (var i = 1; i <= 10; i++) {
                                    ret += '<option value="'+ i +'" '+ setSelected(i, workflow_escalation_period) +'>'+ i +'</option>';
                                };
                                ret += '</select>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    // ret += '<br /><br /><br /><br />';
                    ret += '<div class="clearfix"></div>';
                    ret += '<div style="float: left;width:32%;margin-right:10px" class="container-fields f_enabled">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields css-checkbox" style="margin-right:5px" id="f_enabled_2"><label for="f_enabled_2" class="css-label"></label> Field Enabled: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldEnabled css-checkbox" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_enabled,form_fields[i]) +' id="ID_field_' + form_fields[i] + '"/><label for="ID_field_' + form_fields[i] + '" class="css-label"></label> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-enabled" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_enabled +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    
                    ret += '<div style="float:left;width:32%;margin-right:10px" class="container-fields f_required">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields css-checkbox" style="margin-right:5px" id="f_required_2"><label for="f_required_2" class="css-label"></label> Field Required: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below" style="text-align: right;">';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-required" data-properties-type="lblFldName" data-object-id="" placeholder="Status" value="'+ workflow_field_required +'">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldRequired css-checkbox" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_required,form_fields[i]) +' id="Required2_' + form_fields[i] + '"/><label for="Required2_' + form_fields[i] + '" class="css-label"></label> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float: left;width:32%;" class="container-fields f_hidden">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields css-checkbox" style="margin-right:5px" id="f_hidden_2"><label for="f_hidden_2" class="css-label"></label> Field Hidden: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldHiddenValue css-checkbox" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_hidden,form_fields[i]) +' id="Hidden2_' + form_fields[i] + '"/><label for="Hidden2_' + form_fields[i] + '" class="css-label"></label> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-hidden" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_hidden +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float: left;width:23%;display:none" class="container-fields f_readOnly">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields" style="margin-right:5px">Field Read Only: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldReadOnly" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_read_only,form_fields[i]) +'/> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-hidden" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_hidden +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';

                    
                ret += '</div>';
            ret += '</div>';
            return ret;
            break;
        //WORKFLOW - START NODE
        case "workflow_chart-start":
            var workflow_status = if_undefinded(json_nodes_var[''+ parent_id +'']['status'],"");
            var workflow_field_enabled = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldEnabled'],"");
            var workflow_field_required = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldRequired'],"");
            var workflow_field_hidden = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldHiddenValue'],"");
            var workflow_field_read_only = if_undefinded(json_nodes_var[''+ parent_id +'']['fieldReadOnly'],"");
            var workflow_processor_button = if_undefinded(json_nodes_var[''+ parent_id +'']['buttonStatus'],"");
            var workflow_default_action = if_undefinded(json_nodes_var[''+ parent_id +'']['workflow-default-action'],"");
            var workflow_escalation_period = if_undefinded(json_nodes_var[''+ parent_id +'']['workflow-escalation-period'],"");
            var form_fields = $(".form_fields").val();
            form_fields = JSON.parse(form_fields);
            ret += '<div id="content-dialog-scroll" style="position: relative; margin: 0px auto; padding: 0px; width: 100%; overflow: hidden;" class="ps-container">';
                ret +='<div class="content-dialog" style="height: auto;">';
                    ret += '<div style="float:left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Default Action:</div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select" id="workflow-default-action" style="margin-top:0px;">';
                                ret += '<option value="0">--Select--</option>';
                                if(workflow_processor_button){
                                    for(var i in workflow_processor_button){
                                        ret += '<option value="'+ workflow_processor_button[i]['child_id'] +'" '+ setSelected(workflow_processor_button[i]['child_id'], workflow_default_action) +'>'+ workflow_processor_button[i]['button_name'] +'</option>';
                                    }
                                }
                                ret += '<option value="cancel" '+ setSelected('cancel', workflow_default_action) +'>Cancel</option>';
                                ret += '</select>';
                                ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:30%;margin-right:10px">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Escalation Period(Day/s): </div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select" id="workflow-escalation-period" style="margin-top:0px">';
                                // ret += '<option value="0">--Select--</option>';
                                for (var i = 1; i <= 10; i++) {
                                    ret += '<option value="'+ i +'" '+ setSelected(i, workflow_escalation_period) +'>'+ i +'</option>';
                                };
                                ret += '</select>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div class="clearfix"></div>';
                    ret += '<div style="float: left;width:32%;margin-right:10px" class="container-fields f_enabled">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields css-checkbox" style="margin-right:5px" id="f_enabled"><label for="f_enabled" class="css-label"></label> Field Enabled: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldEnabled css-checkbox" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_enabled,form_fields[i]) +' id="Enabled_' + form_fields[i] + '"/><label for="Enabled_' + form_fields[i] + '" class="css-label"></label> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>'; 
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-hidden" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_hidden +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float: left;width:32%;margin-right:10px"  class="container-fields f_required">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields css-checkbox" style="margin-right:5px" id="f_required"><label for="f_required" class="css-label"></label> Field Required: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldRequired css-checkbox" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_required,form_fields[i]) +' id="Required_' + form_fields[i] + '"/><label for="Required_' + form_fields[i] + '" class="css-label"></label> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-hidden" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_hidden +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float: left;width:32%;"  class="container-fields f_hidden">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields css-checkbox" style="margin-right:5px" id="f_hidden"><label for="f_hidden" class="css-label"></label> Field Hidden: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldHiddenValue css-checkbox" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_hidden,form_fields[i]) +' id="Hidden_' + form_fields[i] + '"/><label for="Hidden_' + form_fields[i] + '" class="css-label"></label> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-hidden" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_hidden +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float: left;width:23%;display:none" class="container-fields f_readOnly">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2"><label><input type="checkbox" class="checkAllFields" style="margin-right:5px">Field Read Only: <font color="red"></font></label></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<div  style="background-color:#fff;padding:5px;border:1px solid #ddd;overflow:auto;min-height:100px;">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<label class="tip" title="' + form_fields[i] + '" style="float:left"><input class="fieldReadOnly" type="checkbox" name="field_' + form_fields[i] + '" value="' + form_fields[i] + '" '+ setCheckedFromArray(workflow_field_read_only,form_fields[i]) +'/> <span class="limit-text-wf">' + form_fields[i] + '</span></label><br /><br />';
                                    }
                                ret += '</div>';
                                //ret += '<input type="text" name="" class="form-text obj_prop" id="workflow-field-hidden" data-properties-type="lblName" data-object-id="" placeholder="Label Name" value="'+ workflow_field_hidden +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';


                ret += '</div>';
            ret += '</div>';
            return ret;
            break
        //WORKFLOW - FOR ROUTE SETTINGS BEFORE CREATING LINE(BUTTONS)
        case "workflow_chart_buttons":
            var form_id = $(".form_chosen").val();
            var buttons_json = json_nodes_var[''+ parent_id +'']['buttonStatus'];
            var wokflow_button_action = $("#"+child_id).find(".node-title").text();
            if($("#"+child_id).attr("data-node-type")=="circle"){
                wokflow_button_action = $("#"+child_id).find(".node-start-title-label").text();
            }
            ret += '<div class="object_properties_content">';
                ret += '<div class="scrollbarM object_properties_wrapper">';
                    ret += '<div style="float: left;width:45%;">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Button: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select workflow-buttons" style="margin-top:0px">';
                                    ret += '<option value="0">--Select--</option> ';
                                var htmlstring_array = $(".form_buttons").val().split(",");
                                for (var i=0;i<htmlstring_array.length;i++) {
                                    ret += '<option value="'+ htmlstring_array[i] +'" '+ hasButton(htmlstring_array[i],buttons_json) +'>'+ htmlstring_array[i] +'</option> ';
                                }
                                ret += '</select>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:right;width:45%;display:none">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Action <font color="red">*</font></div>';
                            ret += '<div class="input_position_below" style="text-align: right;">';
                                ret += '<input type="text" name="" class="form-text obj_prop" readonly="readonly" id="wokflow_button-action" data-properties-type="lblFldName" data-object-id="" placeholder="Next Processor" value="'+ wokflow_button_action +'" child_id = "'+ child_id +'" parent_id = "'+ parent_id +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:right;width:45%;">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Line Color: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below" style="">';
                                ret += '<input type="text" class="chngColor" id="wokflow_button-line-color" data-properties-type="nodeColor" value="#424242"/>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:100%;">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Message: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below" style="">';
                                ret += '<textarea class="msgModalProcess form-textarea" style="resize:none;width:100%;height:100%;margin:0px;" id="msgModalProcess" data-properties-type="dataModalMsg">'+ msgModaldefault +'</textarea>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float: left;width:45%;display:none">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Require Comment:</div>';
                            ret += '<div class="input_position_below">';
                                ret += '<label>';
                                    ret += '<input type="checkbox" name="" class="obj_prop" id="wokflow_button-require">';
                                    ret += '<span style="margin-left: 5px;font-size: 11px;">Do you want to require comment?</span>';
                                ret += '</label>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                ret += '</div>';
            ret += '</div>';
            return ret;
            break;
        //WORKFLOW - CONDITION NODE
        case "workflow_chart-condition":
            var wokflow_condition_fields = if_undefinded(json_nodes_var[''+ parent_id +'']['field'],"");
            var wokflow_condition_operator = if_undefinded(json_nodes_var[''+ parent_id +'']['operator'],"");
            var wokflow_condition_value = if_undefinded(json_nodes_var[''+ parent_id +'']['field_value'],"");
            var form_fields = $(".form_fields").val();
            form_fields = JSON.parse(form_fields);
            ret += '<div class="object_properties_content">';
                ret += '<div class="scrollbarM object_properties_wrapper">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Fields: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below ">';
                                ret += '<select class="form-select wokflow_condition-fields" style="margin-top:0px">';
                                    for (i in form_fields) {
                                        //console.log(form_fields)
                                        ret += '<option value="'+ form_fields[i] +'" '+ setSelected(form_fields[i], wokflow_condition_fields) +'>'+ form_fields[i] +'</option> ';
                                    }
                            ret += '</select>';
                            ret += '</div>';
                        ret += '</div>';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Operator: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<select class="form-select wokflow_condition-operator" style="margin-top:0px">';
                                        ret += '<option value="==" '+ setSelected('==', wokflow_condition_operator) +'>Equal (==)</option>';
                                        ret += '<option value=">" '+ setSelected('>', wokflow_condition_operator) +'>Greater than (>)</option> ';
                                        ret += '<option value="<" '+ setSelected('<', wokflow_condition_operator) +'>Less than (<)</option> ';
                                        ret += '<option value=">=" '+ setSelected('>=', wokflow_condition_operator) +'>Greater than equal (>=)</option>';
                                        ret += '<option value="<=" '+ setSelected('<=', wokflow_condition_operator) +'>Less than equal (<=)</option>';
                                        ret += '<option value="!=" '+ setSelected('!=', wokflow_condition_operator) +'>Not equal (!=)</option>';
                                ret += '</select>';
                            ret += '</div>';
                        ret += '</div>';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Value: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<input type="text" name="" class="form-text"  id="wokflow_condition-value" data-properties-type="lblFldName" data-object-id="" placeholder="Value" value="'+ wokflow_condition_value +'">';
                            ret += '</div>';
                        ret += '</div>';
                ret += '</div>';
            ret += '</div>';
            return ret;
            break;
        //WORKFLOW - FOR ROUTE SETTINGS BEFORE CREATING LINE(CONDITION)
        case "workflow_chart_condition-line":
            var wokflow_condition_action = $("#"+child_id).find(".node-title").text();
            var workflow_condition_return = if_undefinded(json_nodes_var[''+ parent_id +'']['condition_return'],"");
            var hastrue = "";var hasfalse = "";
            if($("#"+child_id).attr("data-node-type")=="circle"){
                wokflow_condition_action = $("#"+child_id).find(".node-start-title-label").text();
            }
            if(workflow_condition_return){
                if (json_nodes_var[''+ parent_id +'']['condition_return']['True']) {
                    hastrue = "disabled='disabled'";
                }
                if (json_nodes_var[''+ parent_id +'']['condition_return']['False']) {
                    hasfalse = "disabled='disabled'";
                }
            }
            ret += '<div class="object_properties_content">';
                ret += '<div class="scrollbarM object_properties_wrapper">';
                    ret += '<div style="float: left;width:45%;">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Return Boolean:</div>';
                            ret += '<div class="input_position_below">';
                                ret += '<label style="margin-right:10px">';
                                    ret += '<input type="radio" '+ hastrue +' name="wokflow_condition-return-boolean" class="obj_prop wokflow_condition-return-boolean css-checkbox" id="propRdoTrue" value="True"><label for="propRdoTrue" class="css-label"></label>';
                                    ret += '<span style="margin-left: 5px;font-size: 11px;">True</span>';
                                ret += '</label>';
                                 ret += '<label>';
                                 
                                    ret += '<input type="radio" '+ hasfalse +' name="wokflow_condition-return-boolean" class="obj_prop wokflow_condition-return-boolean css-checkbox" id="propRdoFalse" value="False"><label for="propRdoFalse" class="css-label"></label>';
                                    ret += '<span style="margin-left: 5px;font-size: 11px;">False</span>';
                                ret += '</label>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:right;width:45%;display:none">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Action <font color="red">*</font></div>';
                            ret += '<div class="input_position_below" style="text-align: right;">';
                                ret += '<input type="text" name="" class="form-text obj_prop" readonly="readonly" id="wokflow_condition-action" data-properties-type="lblFldName" data-object-id="" placeholder="Next Processor" value="'+ wokflow_condition_action +'" child_id = "'+ child_id +'" parent_id = "'+ parent_id +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    ret += '<div style="float:left;width:45%;">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Line Color: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below" style="">';
                                ret += '<input type="text" class="chngColor" id="wokflow_condition-line-color" data-properties-type="lineColor" value="#424242"/>';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                ret += '</div>';
            ret += '</div>';
            return ret;
            break;
        case "workflow_chart-end":
            var workflow_end_status  = if_undefinded(json_nodes_var[''+ parent_id +'']['status'],"");
            ret += '<div class="object_properties_content">';
                ret += '<div class="scrollbarM object_properties_wrapper">';
                    ret += '<div class="fl-end-workflow">';
                        ret += '<div class="fields_below">';
                            ret += '<div class="label_below2">Status: <font color="red">*</font></div>';
                            ret += '<div class="input_position_below">';
                                ret += '<input type="text" name="" class="form-text obj_prop" id="workflow_end-status" data-properties-type="lblFldName" data-object-id="" placeholder="Status" value="'+ workflow_end_status +'">';
                            ret += '</div>';
                        ret += '</div>';
                    ret += '</div>';
                    
                    
                ret += '</div>';
            ret += '</div>';
            return ret;
            break;
        case "workflow_chart-email":
            var workflow_email  = if_undefinded(json_nodes_var[''+ parent_id +'']['workflow_email'],"");
            var workflow_sms  = if_undefinded(json_nodes_var[''+ parent_id +'']['workflow_sms'],"");
            var email_title_type = "0";
            var email_message_type = "0";
            var incRequesLog = "0";
            var email_title = "";
            var email_message = "";
            var departments_to = [];var positions_to = [];var users_to = [];
            var departments_cc = [];var positions_cc = [];var users_cc = [];
            var departments_bcc = [];var positions_bcc = [];var users_bcc = [];
            //
            if(workflow_email){
                //to
                var to = workflow_email['email_recpient'];
                departments_to = to['departments'];
                positions_to = to['positions'];
                users_to = to['users'];
                //cc
                var cc = workflow_email['email_cc'];
                departments_cc = cc['departments'];
                positions_cc = cc['positions'];
                users_cc = cc['users'];
                //bcc
                var bcc = workflow_email['email_bcc'];
                departments_bcc = bcc['departments'];
                positions_bcc = bcc['positions'];
                users_bcc = bcc['users'];

                //message and title
                email_title =   workflow_email['title'];
                email_message = workflow_email['message'];
                email_title_type = workflow_email['email-title-type'];
                email_message_type = workflow_email['email-message-type'];
                incRequesLog = workflow_email['requestLog'];
            }
            var sms_departments = [];var sms_positions = [];var sms_users = [];
            var sms_contact = "";var sms_message = "";var sms_message_type = "0";
            if(workflow_sms){
                sms_departments = workflow_sms['departments'];
                sms_positions = workflow_sms['positions'];
                sms_users = workflow_sms['users'];
                sms_contact =   workflow_sms['contact'];
                sms_message = workflow_sms['message'];
                sms_message_type = workflow_sms['message-type'];
            }
            //console.log(departments_to);
            ret += '<div class="object_properties_content">';
                ret += '<div class="content-dialog-scroll-container" style="position: relative; padding: 0px;  max-height: 500px;overflow: hidden;" class="ps-container-a">';
                    ret +='<div class="content-dialog-container" style="width: 95%;height: auto;">';
                        ret += '<div id="accordion-container" class="flas">';
                        ret += '    <ul>';
                        ret += '        <li><a href="#tabs-1">SMS</a></li>';
                        ret += '        <li><a href="#tabs-2">E-Mail</a></li>';
                        ret += '    </ul>';
                        ret += '   <div id="tabs-1">';
                            //ret += '<label>SMS</label>';
                                ret += '<div>';
                                ret += '<div class="fp-container sms-users">';
                                    ret += '<div style="width:100%;display:inline-block">';
                                        ret += '<div style="width:30%;float:left"><label class="font-bold"><input type="checkbox" class="sms-requestor css-checkbox" value="All Users" id="sms-requestor"/><label for="sms-requestor" class="css-label"></label> Requestor</label></div>';
                                        ret += '<div style="width:50%;float:left"><label class="font-bold"><input type="checkbox" class="sms-processor css-checkbox" value="All Users" id="sms-processor"/><label for="sms-processor" class="css-label"></label> Next Processor</label> </div>';
                                    ret += '</div>';
                                    ret += '<label><input type="checkbox" class="fp-allUsers css-checkbox" value="All Users" id="fp-allUsers4"/><label for="fp-allUsers4" class="css-label"></label> All Users</label> <br />';

                                     ret += '<div class="content-dialog-scroll" style="position: relative; margin-left: 20px; padding: 0px; width: 100%; height: 240px;overflow: hidden;" class="ps-container">';

                                         ret +='<div class="content-dialog" style="width: 90%;height: auto;">';

                                    //ret += '<div style="margin-left: 20px;max-height:240px;overflow-y:auto;overflow-x:hidden">';
                                    // for department
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getDepartmentFF" ><label class="fa fa-minus"></label> <label class="font-bold">Department</label></div>';
                                        ret += '<div class="getDepartmentFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                        var departments = $(".departments").text();
                                        var ctr_dept = 0;
                                        if(departments){
                                            departments = JSON.parse(departments);
                                            $.each(departments,function(key, val){
                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                //setCheckedArray(value, arr)
                                                    ret += '<label class="tip" title="' + val.department + '"><input type="checkbox" class="fp-user fp-user-sms departments css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, sms_departments) +' value="'+ val.id +'" id="fp-user-sms_dept_'+ val.id +'"/><label for="fp-user-sms_dept_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.department +'</span></label>';
                                                ret += '</div>';
                                                ctr_dept++
                                            })
                                        }
                                        if(ctr_dept==0){
                                            ret += '<span style="color:red">No Department</span>';
                                        }
                                        ret += '</div>';
                                    ret += '</div>';
                                    // for position
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getPositionFF" ><label class="fa fa-minus"></label> <label class="font-bold">Position</label></div>';
                                        ret += '<div class="getPositionFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                            var positions = $(".positions").text();
                                            var ctr_pos = 0;
                                            if(positions){
                                                positions = JSON.parse(positions);

                                                $.each(positions,function(key, val){
                                                    if(val.position !=""){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                            ret += '<label class="tip" title="' + val.position + '"><input type="checkbox" class="fp-user fp-user-sms positions css-checkbox" '+ RequestPivacy.setCheckedArray(val.position, sms_positions) +' value="'+ val.position +'" id="Position_' + val.position + '"/><label for="Position_' + val.position + '" class="css-label"></label> <span class="limit-text-wf">'+ val.position +'</span></label>';
                                                        ret += '</div>';
                                                        ctr_pos++;
                                                    }
                                                })
                                                
                                            }
                                            if(ctr_pos==0){
                                                ret += '<span style="color:red">No Positions</span>';
                                            }
                                        ret += '</div>';
                                    
                                     ret += '</div>';
                                        //for users
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getUsersFF" ><label class="fa fa-minus"></label> <label class="font-bold">Users</label></div>';
                                            ret += '<div class="getUsersFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                var users = $(".users").text();
                                                if(users){
                                                    users = JSON.parse(users);
                                                    $.each(users,function(key, val){
                                                        ret += '<div style="width:30%;float:left; margin-bottom:2px;"> ';
                                                            ret += '<label class="tip" title="'+ val.first_name +' '+ val.last_name +'"><input type="checkbox" class="fp-user fp-user-sms users css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, sms_users) +' value="'+ val.id +'" id="IDuser_'+ val.id +'"/><label for="IDuser_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.first_name +' '+ val.last_name +'</span></label>';
                                                        ret += '</div>';
                                                    })
                                                    ret += '</div>';
                                                }
                                        ret += '</div>';
                                    ret += '</div>';
                                    ret += '</div>';
                                ret += '</div>'; 
                                ret += '<div style="width:100%;">';
                                        ret += '<div class="fields_below">';
                                            ret += '<div class="label_below2">Other Recipient: </div>';
                                            ret += '<div class="input_position_below" style="text-align: right;">';
                                                ret += '<input type="text" name="" class="form-text tip" title="Number should be Semicolon separated" id="workflow-sms-contact" placeholder="Title" value="'+ sms_contact +'">';
                                            ret += '</div>';
                                        ret += '</div>';
                                    ret += '</div>';
                                    ret += '<div style="width:100%;" class="formulaContainer">';
                                        ret += '<div class="fields_below">';
                                            ret += '<div class="" style="float:right;width:30%;margin: 5px 0px;font-size: 10px;font-weight: bold;">';
                                            ret += '    <label>Static: <input type="radio" '+ RequestPivacy.setCheckedArray("0", sms_message_type) +' name="workflow-sms-message-type" class="workflow-sms-message-type formulaType css-checkbox" value="0" id="workflow-sms-message-type0"><label for="workflow-sms-message-type0" class="css-label"></label></label>';
                                            ret += '    <label>Dynamic: <input type="radio" '+ RequestPivacy.setCheckedArray("1", sms_message_type) +' name="workflow-sms-message-type" class="workflow-sms-message-type formulaType css-checkbox" value="1" id="workflow-sms-message-type1"><label for="workflow-sms-message-type1" class="css-label"></label><label>';
                                            ret += '</div>';
                                            ret += '<div class="label_below2" style="">Message: </div>';
                                            ret += '<div class="clearfix"></div>';
                                            ret += '<div class="input_position_below" style="text-align: right;">';
                                                ret += '<textarea class="form-textarea wfSettings formulaSMS" placeholder="Message" id="workflow-sms-message" style="height:70px">'+ sms_message +'</textarea>';
                                            ret += '</div>';
                                        ret += '</div>';
                                    ret += '</div>';
                                ret += '</div>';
                        ret += '    </div>';
                        ret += '    <div id="tabs-2">';
                                ret += '<div class="scrollbarM">';
                                    //start accordion
                                    ret += '<div id="accordion">';

                                        //start to
                                        ret += '<label>To:</label>';
                                        ret += '<div class="fp-container email-to">';
                                            ret += '<div style="width:100%;display:inline-block">';
                                                ret += '<div style="width:30%;float:left"><label class="font-bold"><input type="checkbox" class="email-requestor css-checkbox" value="All Users" id="email-requestor"/><label for="email-requestor" class="css-label"></label> Requestor</label></div>';
                                                ret += '<div style="width:50%;float:left"><label class="font-bold"><input type="checkbox" class="email-processor css-checkbox" value="All Users" id="email-processor"/><label for="email-processor" class="css-label"></label> Next Processor</label> </div>';
                                            ret += '</div>';
                                            ret += '<label><input type="checkbox" class="fp-allUsers css-checkbox" value="All Users" id="fp-allUsers5"/><label for="fp-allUsers5"class="css-label"></label> All Users</label> <br />';

                                             ret += '<div class="content-dialog-scroll" style="position: relative; margin-left: 20px; padding: 0px; width: 100%; height: 240px;overflow: hidden;" class="ps-container">';

                                                 ret +='<div class="content-dialog" style="width: 90%;height: auto;">';

                                            //ret += '<div style="margin-left: 20px;max-height:240px;overflow-y:auto;overflow-x:hidden">';
                                            // for department
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getDepartmentFF" ><label class="fa fa-minus"></label> <label class="font-bold">Department</label></div>';
                                                ret += '<div class="getDepartmentFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                var departments = $(".departments").text();
                                                var ctr_dept = 0;
                                                if(departments){
                                                    departments = JSON.parse(departments);
                                                    $.each(departments,function(key, val){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                        //setCheckedArray(value, arr)
                                                            ret += '<label class="tip" title="' + val.department + '"><input type="checkbox" class="fp-user fp-user-to departments css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, departments_to) +' value="'+ val.id +'" id="fp-user-to_dept_'+ val.id +'"/><label for="fp-user-to_dept_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.department +'</span></label>';
                                                        ret += '</div>';
                                                        ctr_dept++
                                                    })
                                                }
                                                if(ctr_dept==0){
                                                    ret += '<span style="color:red">No Department</span>';
                                                }
                                                ret += '</div>';
                                            ret += '</div>';
                                            // for position
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getPositionFF" ><label class="fa fa-minus"></label> <label class="font-bold">Position</label></div>';
                                                ret += '<div class="getPositionFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                    var positions = $(".positions").text();
                                                    var ctr_pos = 0;
                                                    if(positions){
                                                        positions = JSON.parse(positions);

                                                        $.each(positions,function(key, val){
                                                            if(val.position !=""){
                                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                                    ret += '<label class="tip" title="' + val.position + '"><input type="checkbox" class="fp-user fp-user-to positions css-checkbox" '+ RequestPivacy.setCheckedArray(val.position, positions_to) +' value="'+ val.position +'" id="Positions_TO'+ val.position +'"/><label for="Positions_TO'+ val.position +'" class="css-label"></label> <span class="limit-text-wf">'+ val.position +'</span></label>';
                                                                ret += '</div>';
                                                                ctr_pos++;
                                                            }
                                                        })
                                                        
                                                    }
                                                    if(ctr_pos==0){
                                                        ret += '<span style="color:red">No Positions</span>';
                                                    }
                                                ret += '</div>';
                                            
                                             ret += '</div>';
                                                //for users
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getUsersFF" ><label class="fa fa-minus"></label> <label class="font-bold">Users</label></div>';
                                                    ret += '<div class="getUsersFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                        var users = $(".users").text();
                                                        if(users){
                                                            users = JSON.parse(users);
                                                            $.each(users,function(key, val){
                                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                                    ret += '<label class="tip" title="'+ val.first_name +' '+ val.last_name +'"><input type="checkbox" class="fp-user fp-user-to users css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, users_to) +' value="'+ val.id +'" id="2UsersTO_'+ val.id +'"/><label for="2UsersTO_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.first_name +' '+ val.last_name +'</span></label>';
                                                                ret += '</div>';
                                                            })
                                                            ret += '</div>';
                                                        }
                                                ret += '</div>';
                                            ret += '</div>';
                                            ret += '</div>';
                                        ret += '</div>'; 
                                        //end to
                                        //start cc
                                        ret += '<label>CC:</label>';
                                        ret += '<div  class="fp-container email-cc">';
                                            ret += '<div style="width:100%;display:inline-block">';
                                                ret += '<div style="width:30%;float:left"><label class="font-bold"><input type="checkbox" class="email-requestor css-checkbox" value="All Users" id="email-requestor2"/><label for="email-requestor2" class="css-label"></label> Requestor</label></div>';
                                                ret += '<div style="width:50%;float:left"><label class="font-bold"><input type="checkbox" class="email-processor css-checkbox" value="All Users" id="email-processor2"/><label for="email-processor2" class="css-label"></label> Next Processor</label> </div>';
                                            ret += '</div>';
                                            ret += '<label><input type="checkbox" class="fp-allUsers css-checkbox" value="All Users" id="fp-allUsers6"/><label for="fp-allUsers6" class="css-label"></label> All Users</label> <br />';
                                            ret += '<div class="content-dialog-scroll" style="position: relative; margin-left: 20px; padding: 0px; width: 100%; height: 240px;overflow: hidden;" class="ps-container">';

                                                 ret +='<div class="content-dialog" style="width: 90%;height: auto;">';
                                            //ret += '<div style="margin-left: 20px;max-height:240px;overflow-y:auto;overflow-x:hidden">';
                                            // for department
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getDepartmentFF" ><label class="fa fa-minus"></label> <label class="font-bold">Department</label></div>';
                                                ret += '<div class="getDepartmentFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                if(departments){
                                                    $.each(departments,function(key, val){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                        //setCheckedArray(value, arr)
                                                            ret += '<label class="tip" title="'+ val.department +'"><input type="checkbox" class="fp-user fp-user-cc departments css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, departments_cc) +' value="'+ val.id +'" id="fp-user-cc_dept_'+ val.id +'"/><label for="fp-user-cc_dept_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.department +'</span></label>';
                                                        ret += '</div>';
                                                    })
                                                    
                                                }
                                                if(ctr_dept==0){
                                                    ret += '<span style="color:red">No Department</span>';
                                                }
                                                ret += '</div>';
                                            ret += '</div>';
                                            // for position
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getPositionFF" ><label class="fa fa-minus"></label> <label class="font-bold">Position</label></div>';
                                                ret += '<div class="getPositionFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                    
                                                    if(positions){
                                                        $.each(positions,function(key, val){
                                                            if(val.position !=""){
                                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                                    ret += '<label class="tip" title="'+ val.position +'"><input type="checkbox" class="fp-user fp-user-cc positions css-checkbox" '+ RequestPivacy.setCheckedArray(val.position, positions_cc) +' value="'+ val.position +'" id="CCPosition_'+ val.position +'"/><label for="CCPosition_'+ val.position +'" class="css-label"></label> <span class="limit-text-wf">'+ val.position +'</span></label>';
                                                                ret += '</div>';
                                                            }
                                                        })
                                                    }
                                                    if(ctr_pos==0){
                                                        ret += '<span style="color:red">No Positions</span>';
                                                    }
                                                ret += '</div>';
                                            ret += '</div>';
                                                //for users
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getUsersFF" ><label class="fa fa-minus"></label> <label class="font-bold">Users</label></div>';
                                                    ret += '<div class="getUsersFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                        
                                                        if(users){
                                                            $.each(users,function(key, val){
                                                                ret += '<div style="width:30%;float:left; margin-bottom:2px;"> ';
                                                                    ret += '<label class="tip" title="'+ val.first_name +' '+ val.last_name +'"><input type="checkbox" class="fp-user fp-user-cc users css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, users_cc) +' value="'+ val.id +'" id="CCuser_'+ val.id +'"/><label for="CCuser_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.first_name +' '+ val.last_name +'</span></label>';
                                                                ret += '</div>';
                                                            })
                                                            ret += '</div>';
                                                        }
                                                ret += '</div>';
                                            ret += '</div>';
                                        ret += '</div>'; 
                                         ret += '</div>'; 
                                        //end cc
                                        //start bcc
                                        ret += '<label>BCC:</label>';
                                        ret += '<div class="fp-container email-bcc">';
                                            ret += '<div style="width:100%;display:inline-block">';
                                                 ret += '<div style="width:30%;float:left"><label class="font-bold"><input type="checkbox" class="email-requestor css-checkbox" value="All Users" id="email-requestor3"/><label for="email-requestor3" class="css-label"></label> Requestor</label></div>';
                                                ret += '<div style="width:50%;float:left"><label class="font-bold"><input type="checkbox" class="email-processor css-checkbox" value="All Users" id="email-processor3"/><label for="email-processor3" class="css-label"></label> Next Processor</label> </div>';
                                            ret += '</div>';
                                            ret += '<label><input type="checkbox" class="fp-allUsers css-checkbox" value="All Users" id="fp-allUsers1"/><label for="fp-allUsers1" class="css-label"></label> All Users</label> <br />';
                                            ret += '<div class="content-dialog-scroll" style="position: relative; margin-left: 20px; padding: 0px; width: 100%; height: 240px;overflow: hidden;" class="ps-container">';

                                                 ret +='<div class="content-dialog" style="width: 90%;height: auto;">';
                                            // for department
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getDepartmentFF" ><label class="fa fa-minus"></label> <label class="font-bold">Department</label></div>';
                                                ret += '<div class="getDepartmentFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                
                                                if(departments){
                                                    $.each(departments,function(key, val){
                                                        ret += '<div style="width:30%;float:left; margin-bottom:2px;"> ';
                                                        //setCheckedArray(value, arr)
                                                            ret += '<label  class="tip" title="'+ val.department +'"><input type="checkbox" class="fp-user fp-user-bcc departments css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, departments_bcc) +' value="'+ val.id +'" id="bCCUsers_'+ val.id +'"/><label for="bCCUsers_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.department +'</span></label>';
                                                        ret += '</div>';
                                                    })
                                                }
                                                if(ctr_dept==0){
                                                    ret += '<span style="color:red">No Department</span>';
                                                }
                                                ret += '</div>';
                                            ret += '</div>';
                                            // for position
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getPositionFF" ><label class="fa fa-minus"></label> <label class="font-bold">Position</label></div>';
                                                ret += '<div class="getPositionFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                    
                                                    if(positions){
                                                        $.each(positions,function(key, val){
                                                            if(val.position !=""){
                                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                                    ret += '<label class="tip" title="'+ val.position +'"><input type="checkbox" class="fp-user fp-user-bcc positions css-checkbox" '+ RequestPivacy.setCheckedArray(val.position, positions_bcc) +' value="'+ val.position +'" id="BccPosition_'+ val.position +'"/><label for="BccPosition_'+ val.position +'" class="css-label"></label> <span class="limit-text-wf">'+ val.position +'</span></label>';
                                                                ret += '</div>';
                                                            }
                                                        })
                                                      
                                                    }
                                                    if(ctr_pos==0){
                                                        ret += '<span style="color:red">No Positions</span>';
                                                    }
                                                ret += '</div>';
                                            ret += '</div>';
                                                //for users
                                            ret += '<div class="container-formUser">';
                                                ret += '<div class="formUser" rel="getUsersFF" ><label class="fa fa-minus"></label> <label class="font-bold">Users</label></div>';
                                                    ret += '<div class="getUsersFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                        
                                                        if(users){
                                                            $.each(users,function(key, val){
                                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                                    ret += '<label class="tip" title="'+ val.first_name +' '+ val.last_name +'"><input type="checkbox" class="fp-user fp-user-bcc users css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, users_bcc) +' value="'+ val.id +'" id="Users_BCC_'+ val.id +'"/><label for="Users_BCC_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.first_name +' '+ val.last_name +'</span></label>';
                                                                ret += '</div>';
                                                            })
                                                            ret += '</div>';
                                                        }

                                                ret += '</div>';
                                            ret += '</div>';
                                        ret += '</div>'; 
                                        ret += '</div>'; 
                                        //end bcc

                                    ret += '</div>';
                                    //end accordion
                                    ret += '<div style="width:100%;" class="formulaContainer">';
                                        ret += '<div class="fields_below">';
                                            ret += '<div class="" style="float:right;width:30%;margin: 5px 0px;font-size: 10px;font-weight: bold;">';
                                            ret += '    <label>Static: <input type="radio" '+ RequestPivacy.setCheckedArray("0", email_title_type) +' name="workflow-email-title-type" class="workflow-email-title-type formulaType css-checkbox" value="0" id="workflow-email-title-type0"><label for="workflow-email-title-type0" class="css-label"></label></label>';
                                            ret += '    <label>Dynamic: <input type="radio" '+ RequestPivacy.setCheckedArray("1", email_title_type) +' name="workflow-email-title-type" class="workflow-email-title-type formulaType css-checkbox" value="1" id="workflow-email-title-type1"><label for="workflow-email-title-type1" class="css-label"></label></label>';
                                            ret += '</div>';
                                            ret += '<div class="label_below2" style="">Title: </div>';
                                            ret += '<div class="clearfix"></div>';
                                            ret += '<div class="input_position_below" style="text-align: right;">';
                                                ret += '<input type="text" name="" class="form-text wfSettings formulaEmail" id="workflow-email-title" placeholder="Title" value="'+ email_title +'">';
                                            ret += '</div>';
                                        ret += '</div>';
                                    ret += '</div>';
                                    ret += '<div style="width:100%;" class="formulaContainer">';
                                        ret += '<div class="fields_below">';
                                            ret += '<div class="" style="float:right;width:30%;margin: 5px 0px;font-size: 10px;font-weight: bold;">';
                                            ret += '    <label>Static: <input type="radio" '+ RequestPivacy.setCheckedArray("0", email_message_type) +' name="workflow-email-message-type" class="workflow-email-message-type formulaType css-checkbox" value="0" id="workflow-email-message-type0"><label for="workflow-email-message-type0" class="css-label"></label></label>';
                                            ret += '    <label>Dynamic: <input type="radio" '+ RequestPivacy.setCheckedArray("1", email_message_type) +' name="workflow-email-message-type" class="workflow-email-message-type formulaType css-checkbox" value="1" id="workflow-email-message-type1"><label for="workflow-email-message-type1" class="css-label"></label></label>';
                                            ret += '</div>';
                                            ret += '<div class="label_below2" style="">Message: </div>';
                                            ret += '<div class="clearfix"></div>';
                                            ret += '<div class="input_position_below" style="text-align: right;">';
                                                ret += '<textarea class="form-textarea wfSettings formulaEmail" placeholder="Message" id="workflow-email-message" style="height:70px">'+ email_message +'</textarea>';
                                            ret += '</div>';
                                        ret += '</div>';
                                    ret += '</div>';
                                    ret += '<div style="width:100%;">';
                                        ret += '<div class="fields_below">';
                                            ret += '<div class="label_below2" style=""><label><input type="checkbox" class="css-checkbox" value="1" id="incRequesLog" '+ RequestPivacy.setCheckedArray("1", incRequesLog) +'><label for="incRequesLog" class="css-label"></label> Do you want to include Request logs?<label></div>';
                                            ret += '<div class="input_position_below" style="text-align: right;">';
                                            ret += '</div>';
                                        ret += '</div>';
                                    ret += '</div>';
                                ret += '</div>';
                        ret += '    </div>';
                            
                            ret += '</div>';
                        ret += '</div>';
                     ret += '</div>';
                ret += '</div>';
            return ret;
            break;
        // case "workflow_chart-fields-trigger":
        //     var form_fields = $(".form_fields").val();
        //     var forms = $(".company_forms").text();
        //     form_fields = JSON.parse(form_fields);
        //     forms = JSON.parse(forms);
        //     ret += '<div id="content-dialog-scroll" style="position: relative; margin: 0px auto; padding: 0px; width: 100%; height: 300px;overflow: hidden;" class="ps-container">';
        //     ret +='<div class="content-dialog" style="width: 95%;height: auto;">';
        //         ret += '<div class="trigger-container-fields" style="">';
        //             ret += '<div style="float: left;width:23%;margin-right:10px">';
        //                 ret += '<div class="fields_below">';
        //                     ret += '<div class="label_below2">Action: <font color="red">*</font></div>';
        //                     ret += '<div class="input_position_below">';
        //                     ret += '<div style="font-size:11px"><label><input type="radio" name="workflow-trigger-action" value="Update" checked="checked" class="workflow-trigger-action"><span> Update Field</span></label></div>';
        //                     ret += '<div style="font-size:11px"><label><input type="radio" name="workflow-trigger-action" value="Create"  class="workflow-trigger-action"><span> Create Request</span></label></div>';
        //                     ret += '</div>';
        //                 ret += '</div>';
        //             ret += '</div>';
        //             //FOR UPDATE TRIGGER
        //             ret += '<div class="forUpdateTrgger">';
        //                 ret += '<div style="float:left;width:23%;margin-right:10px">';
        //                     ret += '<div class="fields_below" id="forFieldFilter">';
        //                         ret += '<div class="label_below2">Field Filter: <font color="red">*</font></div>';
        //                         ret += '<div class="input_position_below">';
        //                             ret += '<select class="form-select" id="workflow-trigger-fields-filter" style="margin-top:0px">';
        //                             for (i in form_fields) {
        //                                 // console.log(form_fields)
        //                                 ret += '<option>'+ form_fields[i] +'</option>';
        //                             }
        //                             ret += '</select>';
        //                             ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
        //                         ret += '</div>';
        //                     ret += '</div>';
        //                 ret += '</div>';
        //                 ret += '<div style="float:left;width:23%;margin-right:10px">';
        //                     ret += '<div class="fields_below" id="forFieldUpdate">';
        //                         ret += '<div class="label_below2">Field Update: <font color="red">*</font></div>';
        //                         ret += '<div class="input_position_below">';
        //                             ret += '<select class="form-select" id="workflow-trigger-fields-update" style="margin-top:0px">';
        //                             for (i in form_fields) {
        //                                 // console.log(form_fields)
        //                                 ret += '<option>'+ form_fields[i] +'</option>';
        //                             }
        //                             ret += '</select>';
        //                             ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
        //                         ret += '</div>';
        //                     ret += '</div>';
        //                 ret += '</div>';
        //                 ret += '<div id="forOperator" style="float:left;width:23%;margin-right:10px">';
        //                     ret += '<div class="fields_below">';
        //                         ret += '<div class="label_below2">Operator: <font color="red">*</font></div>';
        //                         ret += '<div class="input_position_below">';
        //                             ret += '<select class="form-select" id="workflow-trigger-operator" style="margin-top:0px">';
        //                                 ret += '<option value="Addition">Addition</option>'
        //                                 ret += '<option value="Subtraction">Subtraction</option>'
        //                                 ret += '<option value="Multiplication">Multiplication</option>'
        //                                 ret += '<option value="Division">Division</option>'
        //                             ret += '</select>';
        //                         ret += '</div>';
        //                     ret += '</div>';
        //                 ret += '</div>';
        //             ret += '</div>';
        //             //FOR CREATE TRIGGER
        //             ret += '<div class="forCreateTrgger display">';
        //                 ret += '<div style="float:left;width:35%;margin-right:10px">';
        //                      ret += '<div class="fields_below" id="forFormTrigger">';
        //                         ret += '<div class="label_below2">Form Trigger: <font color="red">*</font></div>';
        //                         ret += '<div class="input_position_below">';
        //                             ret += '<select class="form-select" id="workflow-form-trigger" style="margin-top:0px">';
        //                                 ret += '<option value="0">--Select Form--</option>';
        //                             for (i in forms) {
        //                                 // console.log(form_fields)
        //                                 ret += '<option value="'+ forms[i]['id'] +'">'+ forms[i]['form_name'] +'</option>';
        //                             }
        //                             ret += '</select>';
        //                             ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
        //                         ret += '</div>';
        //                     ret += '</div>';
        //                 ret += '</div>';
        //                 ret += '<div style="float:left;width:35%;margin-right:10px">';
        //                     ret += '<div class="fields_below" id="forReferenceField">';
        //                         ret += '<div class="label_below2">Refence Field: <font color="red">*</font></div>';
        //                         ret += '<div class="input_position_below">';
        //                             ret += '<select class="form-select" id="workflow-reference-fields-update" style="margin-top:0px">';
        //                             ret += '<option value="0">--Select Field--</option>';
        //                             ret += '</select>';
        //                             ret += '<img src="/images/loader/loading.gif" class="pull-left display processorLoad"/>';
        //                         ret += '</div>';
        //                     ret += '</div>';
        //                 ret += '</div>';
        //             ret += '</div>';


        //         ret += '</div>';
        //         ret += '</div>';
        //     ret += '</div>';
        //     return ret;


        // break;
        //multi
        
        case "workflow_chart-fields-trigger":
            var form_fields = $(".form_fields").val();
            var forms = $(".company_forms").text();
            forms = JSON.parse(forms);
            form_fields = JSON.parse(form_fields);
            ret += '<div id="content-dialog-scroll" style="position: relative; margin: 0px auto; padding: 0px; width: 100%; min-height: 300px;max-height: 350px;overflow: hidden;" class="ps-container">';
            ret +='<div class="content-dialog trigger-container" style="width: 95%;height: auto;">';
                ret += workflow_actions.trigger_html(0,"");
            ret += '</div>';
        ret += '</div>';

        return ret;
        break;
        case "workflow_chart-user_setup" :
            var users = if_undefinded(json_nodes_var[''+ parent_id +'']['users'],"");
            var departments_editor = "";
            var positions_editor = "";
            var users_editor = "";
            var departments_viewer = "";
            var positions_viewer = "";
            var users_viewer = "";
            if(users){
                //user_editor
                var user_editor = users['user_editor'];
                departments_editor = user_editor['departments'];
                positions_editor = user_editor['positions'];
                users_editor = user_editor['users'];
                var user_viewer = users['user_viewer'];
                departments_viewer = user_viewer['departments'];
                positions_viewer = user_viewer['positions'];
                users_viewer = user_viewer['users'];
            }
            ret += '<div class="object_properties_content">';
                ret += '<div class="content-dialog-scroll-container" style="position: relative; padding: 0px; max-height: 530px;overflow: hidden;" class="ps-container-a">';
                    ret +='<div class="content-dialog-container" style="width: 95%;height: auto;">';
                         ret += '<div id="accordion-container">';
                            ret += '    <ul>';
                            ret += '        <li><a href="#tabs-1">Editor</a></li>';
                            ret += '        <li><a href="#tabs-2">Viewer</a></li>';
                            ret += '    </ul>';
                            ret += '   <div id="tabs-1">';            
                            //start user_editor
                                // ret += '<label>User Editor:</label>';
                                ret += '<div class="fp-container users-editor">';
                                    ret += '<div style="width:100%;display:inline-block">';
                                        ret += '<div style="width:30%;float:left"><label class="font-bold"><input type="checkbox" class="user-requestor css-checkbox" value="All Users" id="user-requestor"/><label for="user-requestor" class="css-label"></label> Requestor</label></div>';
                                        // ret += '<div style="width:50%;float:left"><label class="font-bold"><input type="checkbox" class="user-processor" value="All Users"/> Next Processor</label> </div>';
                                    ret += '</div>';
                                    ret += '<label><input type="checkbox" class="fp-allUsers css-checkbox" value="All Users" id="fp-allUsers2"/><label for="fp-allUsers2" class="css-label"></label> All Users</label> <br />';

                                     ret += '<div class="content-dialog-scroll" style="position: relative; margin-left: 20px; padding: 0px; width: 100%; height: 240px;overflow: hidden;" class="ps-container">';

                                         ret +='<div class="content-dialog" style="width: 90%;height: auto;">';

                                    //ret += '<div style="margin-left: 20px;max-height:240px;overflow-y:auto;overflow-x:hidden">';
                                    // for department
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getDepartmentFF" ><label class="fa fa-minus"></label> <label class="font-bold">Department</label></div>';
                                        ret += '<div class="getDepartmentFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                        var departments = $(".departments").text();
                                        var ctr_dept = 0;
                                        if(departments){
                                            departments = JSON.parse(departments);
                                            $.each(departments,function(key, val){
                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                //setCheckedArray(value, arr)
                                                    ret += '<label class="tip" title="' + val.department + '"><input type="checkbox" class="fp-user fp-user-to departments css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, departments_editor) +' value="'+ val.id +'" id="fp-user-to_dept_2_'+ val.id +'"/><label for="fp-user-to_dept_2_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.department +'</span></label>';
                                                ret += '</div>';
                                                ctr_dept++
                                            })
                                        }
                                        if(ctr_dept==0){
                                            ret += '<span style="color:red">No Department</span>';
                                        }
                                        ret += '</div>';
                                    ret += '</div>';
                                    // for position
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getPositionFF" ><label class="fa fa-minus"></label> <label class="font-bold">Position</label></div>';
                                        ret += '<div class="getPositionFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                            var positions = $(".positions").text();
                                            var ctr_pos = 0;
                                            if(positions){
                                                positions = JSON.parse(positions);

                                                $.each(positions,function(key, val){
                                                    if(val.position !=""){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                            ret += '<label class="tip" title="' + val.position + '"><input type="checkbox" class="fp-user fp-user-to positions css-checkbox" '+ RequestPivacy.setCheckedArray(val.position, positions_editor) +' value="'+ val.position +'" id="Editor_'+ val.position +'"/><label for="Editor_'+ val.position +'" class="css-label"></label> <span class="limit-text-wf">'+ val.position +'</span></label>';
                                                        ret += '</div>';
                                                        ctr_pos++;
                                                    }
                                                })
                                                
                                            }
                                            if(ctr_pos==0){
                                                ret += '<span style="color:red">No Positions</span>';
                                            }
                                        ret += '</div>';
                                    ret += '</div>';
                                        //for users
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getUsersFF" ><label class="fa fa-minus"></label> <label class="font-bold">Users</label></div>';
                                            ret += '<div class="getUsersFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                var users = $(".users").text();
                                                if(users){
                                                    users = JSON.parse(users);
                                                    $.each(users,function(key, val){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                            ret += '<label class="tip" title="'+ val.first_name +' '+ val.last_name +'"><input type="checkbox" class="fp-user fp-user-to users css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, users_editor) +' value="'+ val.id +'" id="UsersTO_'+ val.id +'"/><label for="UsersTO_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.first_name +' '+ val.last_name +'</span></label>';
                                                        ret += '</div>';
                                                    })
                                                    ret += '</div>';
                                                }
                                        ret += '</div>';
                                    ret += '</div>';
                                ret += '</div>'; 
                                //end user_editor
                                ret += '</div>';
                                ret += '</div>';
                                ret += '   <div id="tabs-2">';            
                            //start viewer_editor
                                // ret += '<label>User Editor:</label>';
                                ret += '<div class="fp-container users-viewer">';
                                    // ret += '<div style="width:100%;display:inline-block">';
                                    //     ret += '<div style="width:30%;float:left"><label class="font-bold"><input type="checkbox" class="user-requestor" value="All Users"/> Requestor</label></div>';
                                    //     ret += '<div style="width:50%;float:left"><label class="font-bold"><input type="checkbox" class="user-processor" value="All Users"/> Next Processor</label> </div>';
                                    // ret += '</div>';
                                    ret += '<label><input type="checkbox" class="fp-allUsers css-checkbox" value="All Users" id="fp-allUsers3"/><label for="fp-allUsers3" class="css-label"></label> All Users</label> <br />';

                                     ret += '<div class="content-dialog-scroll" style="position: relative; margin-left: 20px; padding: 0px; width: 100%; height: 240px;overflow: hidden;" class="ps-container">';

                                         ret +='<div class="content-dialog" style="width: 90%;height: auto;">';

                                    //ret += '<div style="margin-left: 20px;max-height:240px;overflow-y:auto;overflow-x:hidden">';
                                    // for department
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getDepartmentFF" ><label class="fa fa-minus"></label> <label class="font-bold">Department</label></div>';
                                        ret += '<div class="getDepartmentFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                        var departments = $(".departments").text();
                                        var ctr_dept = 0;
                                        if(departments){
                                            departments = JSON.parse(departments);
                                            $.each(departments,function(key, val){
                                                ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                //setCheckedArray(value, arr)
                                                    ret += '<label class="tip" title="' + val.department + '"><input type="checkbox" class="fp-user fp-user-to departments css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, departments_viewer) +' value="'+ val.id +'" id="fp-user-to_dept_3_'+ val.id +'"/><label for="fp-user-to_dept_3_'+ val.id +'"></label> <span class="limit-text-wf">'+ val.department +'</span></label>';
                                                ret += '</div>';
                                                ctr_dept++
                                            })
                                        }
                                        if(ctr_dept==0){
                                            ret += '<span style="color:red">No Department</span>';
                                        }
                                        ret += '</div>';
                                    ret += '</div>';
                                    // for position
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getPositionFF" ><label class="fa fa-minus"></label> <label class="font-bold">Position</label></div>';
                                        ret += '<div class="getPositionFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                            var positions = $(".positions").text();
                                            var ctr_pos = 0;
                                            if(positions){
                                                positions = JSON.parse(positions);

                                                $.each(positions,function(key, val){
                                                    if(val.position !=""){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                            ret += '<label class="tip" title="' + val.position + '"><input type="checkbox" class="fp-user fp-user-to positions css-checkbox" '+ RequestPivacy.setCheckedArray(val.position, positions_viewer) +' value="'+ val.position +'" id="Viewer_'+ val.position +'"/><label for="Viewer_'+ val.position +'" class="css-label"></label> <span class="limit-text-wf">'+ val.position +'</span></label>';
                                                        ret += '</div>';
                                                        ctr_pos++;
                                                    }
                                                })
                                                
                                            }
                                            if(ctr_pos==0){
                                                ret += '<span style="color:red">No Positions</span>';
                                            }
                                        ret += '</div>';
                                    ret += '</div>';
                                        //for users
                                    ret += '<div class="container-formUser">';
                                        ret += '<div class="formUser" rel="getUsersFF" ><label class="fa fa-minus"></label> <label class="font-bold">Users</label></div>';
                                            ret += '<div class="getUsersFF" style="display:inline-block;width:120%;margin-left:10px;margin-top:5px;">';
                                                var users = $(".users").text();
                                                if(users){
                                                    users = JSON.parse(users);
                                                    $.each(users,function(key, val){
                                                        ret += '<div style="width:30%;float:left;margin-bottom:2px;"> ';
                                                            ret += '<label class="tip" title="'+ val.first_name +' '+ val.last_name +'"><input type="checkbox" class="fp-user fp-user-to users css-checkbox" '+ RequestPivacy.setCheckedArray(val.id, users_viewer) +' value="'+ val.id +'" id="Viewer_Users_'+ val.id +'"/><label for="Viewer_Users_'+ val.id +'" class="css-label"></label> <span class="limit-text-wf">'+ val.first_name +' '+ val.last_name +'</span></label>';
                                                        ret += '</div>';
                                                    })
                                                    ret += '</div>';
                                                }
                                        ret += '</div>';
                                    ret += '</div>';
                                ret += '</div>'; 
                                //end user_editor
                                
                                ret += '</div>';
                            ret += '</div>';
                        ret += '</div>';
                     ret += '</div>';
                ret += '</div>';
            return ret;
            break;
        
    }
}
/**OTHER FUNCTIONS***/
function if_undefinded(value,else_value) {
    var ret = "";
    if (value!=undefined && value!="undefined") {
        ret = value;
    }else{
        ret = else_value;
    }
    return ret;
}
function setSelected(value, selectedValue){
    var ret = "";
    if(value == selectedValue){
        ret = "selected = 'selected'";
    }
    return ret;
}
function setChecked(value, selectedValue){
    var ret = "";
    if(value == selectedValue){
        ret = "checked = 'checked'";
    }
    return ret;
}
function hasButton(button_value,button_json) {
    var ret = "";
    if (typeof button_json!="undefined") {
        for (var i in button_json) {
            if (button_value == button_json[i]['button_name']) {
                ret = "disabled = 'disabled'";
            }
        }
    }
    return ret;
}
//Dialog for get form for workflow
function getFormForWorkflow(callback) {
    var form_id = $(".form_chosen").val();
    $.post("/ajax/getFormProperties",{action:"getForm"},function(forms){
        var forms_json = JSON.parse(forms);
        var ret = "";
        ret += '<div style="float:left;width:50%;">';
            ret += '<h3 class="pull-left fl-margin-bottom">';
                ret += '<i class="icon-asterisk"></i> ' + "Get Workspace";
            ret += '</h3>';
        ret += '</div>';
        //ret += '<div style="float:right;width:50%;text-align:right;margin-top:-5px;">';
        //    ret += '<input type="button" class="btn-basicBtn getFormForWorkflow" id="" value="Ok" node-data-id="" style="">';
        //ret += '</div>';
        ret += '<div class="hr"></div>';
                ret += '<div class="fields">';
                    ret += '<div class="label_below2 fl-get-workspace-popup"> Please select a form: </div>';
                    ret += '<div class="input_position">';
                        ret += '<select class="form-select forms_selection fl-margin-bottom" style="margin-top:5px; margin-bottom:5px;">';
                            ret += '<option value="0">----------------------------Select----------------------------</option>';
                            for (var i in forms_json){
                                
                                 ret += '<option value="'+ forms_json[i]['form_id'] +'">'+ forms_json[i]['form_name'] +'</option> ';
                            }
                        ret += '</select>';
                    ret += '</div>';
                ret += '</div>';
                ret += '<div class="fields">';
                    ret += '<div class="label_below2"></div>';
                    ret += '<div class="input_position" style="margin-top:5px;text-align:right;">';
                        ret += '<input type="button" class="btn-blueBtn getFormForWorkflow fl-margin-right" value="Ok"> ';
                        //ret += '<a href="/"><input type="button" class="btn-basicBtn" id="workflow-cancel" value="Cancel"></a>';
                    ret += '</div>';
                ret += '</div>';
        callback(ret);
    })
}

function getUser(parent_id,search,type,callback) {
    
    $.post("/ajax/regUser",{action:"getUser",search:search},function(result){
        var ret = "";
        if(result){
            var user_json = JSON.parse(result);
            var json_nodes = $("body").data();
            var json_nodes_var = json_nodes['nodes'];
            var orgchart_user_head = if_undefinded(json_nodes_var[''+ parent_id +'']['orgchart_user_head'],"");
            var orgchart_dept_assistant = if_undefinded(json_nodes_var[''+ parent_id +'']['orgchart_dept_assistant'],0);
            var orgchart_dept_members = if_undefinded(json_nodes_var[''+ parent_id +'']['orgchart_dept_members'],"");
            var userID = "";
            var name = "";
            var avatar = "";
            var headUser = "";
            var assHeadUser = '';
            var memberUser = "";
            var chk_head = "";
            var chk_assistant = '<label class="orgchart_user_wrap"><img src="/images/avatar/small.png" width="25" height="25" class="avatar userAvatar"><span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="asst_head_user css-checkbox" type="radio" name="assheadUser" '+ setChecked("0", orgchart_dept_assistant) +' value="0" id="assheadUser_' + setChecked("0", orgchart_dept_assistant) + '" /><label for="assheadUser_' + setChecked("0", orgchart_dept_assistant) + '" class="css-label"></label> None</span></label><br />';
            var chk_member = "";
            // orgchart_dept_members = $(".orgchart-user-search").data();
            var orgchartPartialChecked = $(".orgchart-user-search").data();
            orgchartPartialChecked = if_undefinded(orgchartPartialChecked['members_id'],"");
            orgchart_dept_members = orgchart_dept_members.concat(orgchartPartialChecked);

            for (var i in user_json){
                userID = user_json[i].userID;
                name = user_json[i]['name'];
                avatar = "<span class='avatar-oc'>"+user_json[i]['avatar']+"</span>";
                if(setChecked(userID, orgchart_user_head)){
                    chk_head += '<label class="orgchart_user_wrap">'+ avatar +'<span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="head_user css-checkbox" type="radio" name="headUser" checked="checked" value="' + userID + '" id="headUser_' + userID + '"/><label for="headUser_' + userID + '" class="css-label"></label> <span class="limit-text-wf">' + name + '</span></span></label><br />';
                }else{
                    headUser += '<label class="orgchart_user_wrap">'+ avatar +'<span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="head_user css-checkbox" type="radio" name="headUser"  value="' + userID + '" id="headUser_' + userID + '"/><label for="headUser_' + userID + '" class="css-label"></label> <span class="limit-text-wf">' + name + '</span></span></label><br />';
                }
                if(setChecked(userID, orgchart_dept_assistant)){
                    chk_assistant += '<label class="orgchart_user_wrap">'+ avatar +'<span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="asst_head_user css-checkbox" type="radio" name="assheadUser" checked="checked" value="' + userID + '" id="assheadUser_' + userID + '"/><label for="assheadUser_' + userID + '" class="css-label"></label> <span class="limit-text-wf">' + name + '</span></span></label><br />';
                }else{
                    assHeadUser += '<label class="orgchart_user_wrap">'+ avatar +'<span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="asst_head_user css-checkbox" type="radio" name="assheadUser" value="' + userID + '" id="assheadUser_' + userID + '"/><label for="assheadUser_' + userID + '" class="css-label"></label> <span class="limit-text-wf">' + name + '</span></span></label><br />';
                }
                if(setCheckedFromArray(orgchart_dept_members,userID)){
                    chk_member += '<label class="orgchart_user_wrap">'+ avatar +'<span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="member_user css-checkbox" type="checkbox" name="memberUser" checked="checked" value="' + userID + '" id="' + userID + '" /><label for="'+ userID +'" class="css-label"></label> <span class="limit-text-wf">' + name + '</span></span></label><br />';
                }else{
                    memberUser += '<label class="orgchart_user_wrap">'+ avatar +'<span style="position: absolute;margin-top: 7px;margin-left:11px"><input class="member_user css-checkbox" type="checkbox" name="memberUser"   value="' + userID + '" id="' + userID + '" /><label for="' + userID + '" class="css-label"></label> <span class="limit-text-wf">' + name + '</span></span></label><br />';
                }
                    
            }
            headUser += "<br />";
            memberUser+= "<br />";
            if(type==0){
                $(".loadHeadUser").html(chk_head+headUser);
                $(".loadAssistantHeadUser").html(chk_assistant+assHeadUser);
                $(".loadMemberUser").html(chk_member+memberUser);
            }else if(type=="orgchart-head-search"){
                $(".loadHeadUser").html(chk_head+headUser);
            }else if(type=="orgchart-assistant-head-search"){
                $(".loadAssistantHeadUser").html(chk_assistant+assHeadUser);
            }else if(type=="orgchart-member-search"){
                $(".loadMemberUser").html(chk_member+memberUser);
            }
            
            if($(".userLevel").val()!=2){
                $(".member_user, .asst_head_user, .head_user").attr("disabled","disabled");
            }

            callback(1)
        }
    });
}
function setCheckedFromArray(array,value){
    if(array.indexOf(value)>=0){
        return "checked='checked'";
    }else{
        return "";
    }
}

function disabledCheckedOptions(){
    
}
function removeDialog(obj){
    var type = $(obj).attr("object_type");
    var node_data_id = $(obj).attr("node-data-id");
    var json_nodes = $("body").data();
    var json_nodes_var = json_nodes['nodes'];
    if(type=="organizational_chart"){
        // json_nodes_var[''+ node_data_id +'']['node_text'] = "";
        // json_nodes_var[''+ node_data_id +'']['node_color'] = "";
        // json_nodes_var[''+ node_data_id +'']['orgchart_user_head'] = "";
        // json_nodes_var[''+ node_data_id +'']['orgchart_dept_assistant'] = "";
        // json_nodes_var[''+ node_data_id +'']['orgchart_dept_members'] = "";
    }   
}